package cn.dlc.com.graph;

import java.util.Arrays;

/**
 * @author 邓立川
 * @date 2021/3/29 21:45
 * @desc 当前类的描述信息
 */
public class DepthFirstSearchTest {
    public static void main(String[] args) {
        Graph graph = new Graph(13);

        // 根据文档里面构建这个图
        graph.addEdge(0,1);
        graph.addEdge(0,2);
        graph.addEdge(0,5);
        graph.addEdge(0,6);
        graph.addEdge(3,4);
        graph.addEdge(3,5);
        graph.addEdge(4,5);
        graph.addEdge(4,6);

        graph.addEdge(7,8);

        graph.addEdge(9,10);
        graph.addEdge(9,11);
        graph.addEdge(9,12);
        graph.addEdge(11,12);

        // 深度搜索0节点
        DepthFirstSearch depthFirstSearch = new DepthFirstSearch(graph, 0);

        System.out.println(Arrays.toString(depthFirstSearch.getMarked()));
        // 这里把自己也算上了，
        System.out.println("连通的节点有：" + depthFirstSearch.count() +" 个");
        //
        boolean marked = depthFirstSearch.marked(3);
        System.out.println("和顶点3是否相通:" + marked);

        boolean marked2 = depthFirstSearch.marked(7);
        System.out.println("和顶点7是否相通:" + marked2);
    }
}
